home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_mac.hqx / SRGP port to 5.0 (compressed) / SRGP_SPHIGS Root / MacSPHIGS / sph_state.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-14  |  1.8 KB  |  95 lines

  1. #include "HEADERS.h"
  2. #define SPHIGS_BOSS
  3. #include "sphigslocal.h"
  4. #include <math.h>
  5.  
  6. #include "sph_state.proto.h"
  7. static int ResizeCallback(int, int);
  8. static void CheckNotEnabledYet(void);
  9.  
  10.  
  11.  
  12.  
  13. static int
  14. ResizeCallback (int width, int height)
  15. {
  16.    register vi;
  17.  
  18.    SPH_ndcSpaceSizeInPixels = (width>height) ? height : width;
  19.    for (vi=0; vi<=MAX_VIEW_INDEX; vi++) {
  20.       SPH__updateViewInfo (vi);
  21.       SPH__refresh_viewport_change (vi, SPH_viewTable[vi].pdc_viewport);
  22.    }
  23. }   
  24.  
  25.  
  26.  
  27. /*!*/
  28. void SPH_begin (int width, int height, int color_planes_desired, 
  29.         int shades_per_flexicolor)
  30. {
  31.    if (SPH__enabled)
  32.       SPH__error (ERR_ALREADY_ENABLED);
  33.  
  34.    SPH__enabled = TRUE;
  35.  
  36.    /* What should be the size in pixels of 1 NPC unit? */
  37.    SPH_ndcSpaceSizeInPixels = (width>height) ? height : width;
  38.  
  39.    SRGP_begin ("SPHIGS", width, height, color_planes_desired, FALSE);
  40.  
  41.    ALLOC_RECORDS (SPH_viewTable, view_spec, MAX_VIEW_INDEX+1);
  42.    ALLOC_RECORDS (SPH__structureTable, structure, MAX_STRUCTURE_ID+1);
  43.    
  44.    BYTES_PER_BITSTRING = ceil((MAX_STRUCTURE_ID+1.0)/8.0);
  45.  
  46.    SRGP_allowResize (TRUE);
  47.    SRGP_registerResizeCallback (ResizeCallback);
  48.  
  49.    SPH__init_structure_table();
  50.    SPH__initDefaultAttributeGroup();
  51.    SPH__init_view_table();
  52.   
  53.    SPH_setImplicitRegenerationMode (ALLOWED);
  54.  
  55.    SPH__initColorTable (shades_per_flexicolor);
  56. }
  57.  
  58.  
  59.  
  60.  
  61. /*!*/
  62. void
  63. SPH_end(void)
  64. {
  65.    SRGP_end();
  66.    SPH__enabled = FALSE;
  67. }
  68.  
  69.  
  70.  
  71.  
  72. /** ROUTINES ALLOWING APPLICATION TO CHANGE SIZES OF TABLES
  73. These may only be called *before* SPHIGS is enabled.
  74. **/
  75.  
  76. static void CheckNotEnabledYet (void)
  77. {
  78.    if (SPH__enabled)
  79.       SPH__error (ERR_ALREADY_ENABLED);
  80. }
  81.  
  82.  
  83. void SPH_setMaxStructureID (int i)
  84. {
  85.    CheckNotEnabledYet();
  86.    MAX_STRUCTURE_ID = i;
  87. }
  88.  
  89.  
  90. void SPH_setMaxViewIndex (int i)
  91. {
  92.    CheckNotEnabledYet();
  93.    MAX_VIEW_INDEX = i;
  94. }
  95.